package cn.memset.code;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

public class FpExample {
    public static void main(String[] args) {
        simpleFunctinoProgramming();

        // 输出 "cba321"
        System.out.println(reverse("123abc"));
    }

    public static void simpleFunctinoProgramming() {
        List<String> l = Arrays.asList("a", "b", "c");
        Consumer<String> print = s -> System.out.println(s);
        l.forEach(print);
    }

    public static String reverse(final String arg) {
        if (arg.length() == 0) {
            return arg;
        } else {
            return reverse(arg.substring(1)) + arg.substring(0, 1);
        }
    }
}
